//
//  FPDetailCinemaTableViewController.m
//  FilmParadise
//
//  Created by lanou3g on 15/7/15.
//  Copyright (c) 2015年 DLYgroup. All rights reserved.
//

#import "FPDetailCinemaTableViewController.h"
#import "FPCinemaViewController.h"
#import "FPCinemaDetailViewController.h"
#import "FPCinemaDetailViewController.h"

#import "FPDetailCinemaTableViewCell.h"
#import "FPCinemaCollectionViewCell.h"
#import "FPCinemaTableViewCell.h"

#import "FPMovieHotPlayModel.h"
#import "FPPlayDetailModel.h"
#import "FPCinemaModel.h"
#import "FPUserModel.h"

#import "FPSqliteManager.h"
#import "UIImage+WebP.h"
#import "iCarousel.h"
#import "UMSocial.h"

#define kDCinemaUrl @"http://api.m.mtime.cn/Showtime/ShowtimeMovieAndDateListByCinema.api?cinemaId="
#define kPlayMessageUrl @"http://api.m.mtime.cn/Showtime/ShowTimesByCinemaMovieDate.api?cinemaId=%@&date=%@&movieId=%ld"

@interface FPDetailCinemaTableViewController ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,iCarouselDataSource,iCarouselDelegate>

{
    BOOL _ischange;
    BOOL _isClick;
    NSInteger _caIndex;
}
@property (nonatomic, strong) iCarousel *carousel;
@property (nonatomic, strong) FPCinemaDetailViewController *fpcinemaDetailVC;

@property (nonatomic, strong) UILabel *topLabel;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UILabel *typeLabel;
@property (nonatomic, strong) NSMutableArray *set;
@property (nonatomic, strong) NSMutableDictionary *imageDic;
@property (nonatomic, assign) NSInteger imageindex;
@property (nonatomic, strong) UICollectionView *collectionView;

// 存放解析出来的model
//@property (nonatomic, strong) NSMutableArray *titleArray;
@property (nonatomic, strong) NSMutableArray *dateArray;
@property (nonatomic, strong) NSMutableArray *cinemaArray;
@property (nonatomic, strong) NSMutableArray *featureArray;
@property (nonatomic, strong) NSMutableArray *moviesArray;

@property (nonatomic, strong) NSMutableArray * filmArry;
@property (nonatomic, strong) NSMutableArray * playDetailArray;


// 解析影片播放厅信息
@property (nonatomic, copy)   NSString *datakUrl;
@property (nonatomic, assign) NSInteger movieIdkUrl;
@property (nonatomic) NSInteger lblIndex;
@property (nonatomic, strong) MBProgressHUD * HUD;

@end

@implementation FPDetailCinemaTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _caIndex = 0;
    // 左上角返回barbutton
    //   [self B_backBarButton];
    
    // 右上角barbutton
    [self B_rightBarButton];
    
    // 解析数据
    [self T_analisisDetailCinema];
    [self S_analisisPlayMessageMovieId:_movieIdkUrl movieData:_datakUrl];
    
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.translucent = NO;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"cgClear"] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    [self.navigationController.navigationBar setBackgroundColor:[UIColor blueColor]];
    self.navigationController.navigationBar.barTintColor = [UIColor blueColor];
    
}


/*==============================================解析数据=================================================*/
#pragma mark - 解析网络数据
- (void)setUrl
{
    self.HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [self.view bringSubviewToFront:_HUD];
    if ([[FPNetWork shareInstance] rechability]) {
        self.HUD.labelText = @"正在加载";
        // 解析数据
        [self T_analisisDetailCinema];
        [self S_analisisPlayMessageMovieId:_movieIdkUrl movieData:_datakUrl];
    }
    else
    {
        self.HUD.labelText = @"请检查网络";
    }
    
}

- (void)T_analisisDetailCinema
{
    // 创建请求对象
    NSURLRequest *request = [NSURLRequest requestWithURL:
                             [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",kDCinemaUrl,_kUrl]]
                                             cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
    
    //开启异步连接
    [NSURLConnection sendAsynchronousRequest:request
                                       queue:[NSOperationQueue mainQueue]
                           completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
                               if (data == nil) return;
                               NSDictionary *detailDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
                               // 初始化数组
                               self.cinemaArray         = [NSMutableArray array];
                               self.featureArray        = [NSMutableArray array];
                               self.moviesArray         = [NSMutableArray array];
                               //self.titleArray          = [NSMutableArray array];
                               self.set                 = [NSMutableArray array];
                               self.dateArray           = [NSMutableArray array];
                               
                               
                               NSDictionary *cinemaDic  = [detailDic objectForKey:@"cinema"];
                               FPCinemaModel *model     = [FPCinemaModel cinemaModelWithDictionary:cinemaDic];
                               [self.cinemaArray addObject:model];
                               
                               NSDictionary *featureDic = [cinemaDic objectForKey:@"feature"];
                               FPCinemaModel *featureModel = [FPCinemaModel cinemaModelWithDictionary:featureDic];
                               [self.featureArray addObject:featureModel];
                               
                               NSArray *array = [detailDic objectForKey:@"movies"];
                               [array enumerateObjectsUsingBlock:^(NSDictionary *dic, NSUInteger idx, BOOL *stop) {
                                   FPMovieHotPlayModel *model = [FPMovieHotPlayModel MovieHotPlayWithDictionary:dic];
                                   [self.moviesArray addObject:model];
                                   NSMutableArray *littArr = [dic objectForKey:@"showDates"];
                                   [self.dateArray addObject:littArr];
                                   NSString *str = [dic objectForKey:@"img"];
                                   [self.set addObject:str];
                               }];
                               [self.tableView reloadData];
                               [self.HUD hide:YES afterDelay:1];
                           }];
    
}

- (void)S_analisisPlayMessageMovieId:(NSInteger)movieId movieData:(NSString *)movieData
{
    NSString *urlString = [NSString stringWithFormat:kPlayMessageUrl,_kUrl,movieData,movieId];
    NSLog(@"urlString == %@",urlString);
    
    // 创建请求对象
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:kPlayMessageUrl,_kUrl,movieData,movieId]]
                                             cachePolicy:NSURLRequestUseProtocolCachePolicy
                                         timeoutInterval:20.0];
    // 开启异步请求
    [NSURLConnection sendAsynchronousRequest:request
                                       queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
                                           if (data == nil) return;
                                           NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
                                           // 初始化数组
                                           self.filmArry        = [NSMutableArray array];
                                           self.playDetailArray = [NSMutableArray array];
                                           
                                           FPPlayDetailModel *model = [FPPlayDetailModel PlayDetailWithDictionary:dic];
                                           [self.filmArry addObject:model];
                                           NSArray *array = [dic objectForKey:@"s"];
                                           // NSLog(@"s = %@", array);
                                           [array enumerateObjectsUsingBlock:^(NSDictionary *sDic, NSUInteger idx, BOOL *stop) {
                                               FPPlayDetailModel *sModel = [FPPlayDetailModel PlayDetailWithDictionary:sDic];
                                               [self.playDetailArray addObject:sModel];
                                               //                                                  NSLog(@"%@---%@----%ld---%@",sModel.showDay,sModel.startTime,(long)sModel.price,sModel.language);
                                               
                                           }];
                                           [self.tableView reloadData];
                                           [self.HUD hide:YES afterDelay:1];
                                       }];
}


/*==============================================搭建视图=================================================*/
#pragma mark - 搭建视图
// 左上角返回barbutton
- (void)B_backBarButton
{
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back-vector"]  style:UIBarButtonItemStyleDone target:self action:@selector(backButtonAction:)];
    self.navigationItem.leftBarButtonItem = backButton;
}

// 右上角按键
- (void)B_rightBarButton
{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(kScreenWidth - 90, 0, 75, 30)];
    
    UIButton *collectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    collectBtn.frame = CGRectMake(0, 0, 30, 30);
    [collectBtn setBackgroundImage:[UIImage imageNamed:@"collectImage"] forState:UIControlStateNormal];
    [collectBtn setBackgroundImage:[UIImage imageNamed:@"collectImage"] forState:UIControlStateSelected];
    [collectBtn addTarget:self action:@selector(collectionBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:collectBtn];
    
    UIButton *shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    shareBtn.frame = CGRectMake(40, 0, 30, 30);
    [shareBtn setBackgroundImage:[UIImage imageNamed:@"ic_share_blue.png"] forState:UIControlStateNormal];
    [shareBtn addTarget:self action:@selector(shareBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:shareBtn];
    
    UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc] initWithCustomView:view];
    self.navigationItem.rightBarButtonItem = rightBtn;
}

/*==============================================方法实现=================================================*/
#pragma mark - 方法实现
// 是否收藏
- (void)collectionBtnAction:(UIButton *)button
{
    if (![FPUserModel ShareInstance].userName) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"请登录" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [alert show];
        return;
    }
    NSArray *cinemaArray = [FPSqliteManager selectCinemaCollectWithUserName:[FPUserModel ShareInstance].userName];
    FPCinemaModel *model = self.cinemaArray[0];
    if (cinemaArray.count == 0) {
        [FPSqliteManager insertCinemaTable:model];
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"恭喜您" message:@"收藏成功,请在我的影院收藏中查看" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [alert show];
    }else{
        for (NSString *title in cinemaArray) {
            if ([title isEqualToString:model.name]) {
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"亲,您已经收藏过了哦" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
                [alert show];
                return;
            }
        }
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"收藏成功" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [alert show];
    }
    [FPSqliteManager insertCinemaTable:model];
    FPCollectCinemaModel *collectModel = [[FPCollectCinemaModel alloc] init];
    collectModel.name = model.name;
    collectModel.userName   = [FPUserModel ShareInstance].userName;
    [FPSqliteManager insertCinemaCollectTable:collectModel];
}

// 是否分享
- (void)shareBtnAction:(UIBarButtonItem *)button
{
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"55acadd6e0f55a7e410046b0"
                                      shareText:@"好电影要懂得分享"
                                     shareImage:[UIImage imageNamed:@"icon"]
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToTencent,UMShareToQQ,UMShareToRenren,UMShareToDouban,nil]
                                       delegate:nil];
}

// 左上角返回barbutton实现方法
- (void)backButtonAction:(UIBarButtonItem *)button
{
    //[self dismissViewControllerAnimated:YES completion:nil];
    //    FPCinemaViewController *fpc = [[FPCinemaViewController alloc]init];
    //    [self.navigationController popToViewController:fpc animated:YES];
    [self.navigationController popViewControllerAnimated:NO];
}

/*==============================================tableView协议方法=================================================*/
#pragma mark - Table view 方法
// 每行的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return kImageH(90);
}

// 有多少分组
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

// 每个分组有多少行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 1;
    }else{
        return _playDetailArray.count;
    }
}

// 设置表尾高度
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if (section == 0) {
        return 160;
    }else{
        return 0;
    }
}

// 设置表头高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return 0;
    }else{
        return 30;
    }
}

#pragma mark - 设置headerView
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 30) collectionViewLayout:layout];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    self.collectionView.showsHorizontalScrollIndicator = NO;
    self.collectionView.backgroundColor = [UIColor whiteColor];
    
    return _collectionView;
}


#pragma mark - 设置表尾视图
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *view = nil;
    
    if (self.moviesArray.count !=0) {
        FPMovieHotPlayModel *model = _moviesArray[0];
        
        //    view.backgroundColor = [UIColor grayColor];
       view = [self lurImageView];
        view.userInteractionEnabled = YES;
        
        if (_ischange == NO) {
            
            self.carousel = [[iCarousel alloc] initWithFrame:CGRectMake(0, 10, kScreenWidth, 100)];
            self.carousel.delegate = self;
            self.carousel.dataSource = self;
            self.carousel.type = iCarouselTypeRotary;
            
            self.topLabel = [[UILabel alloc] initWithFrame:CGRectMake((kScreenWidth / 2 -80), (105), (160) , (30))];
            self.topLabel.textColor = [UIColor whiteColor];
            self.topLabel.text = model.title;
            self.topLabel.textAlignment = NSTextAlignmentCenter;
            
            self.timeLabel = [UILabel labelWithFrame:CGRectMake(kScreenWidth / 2 -80, 135, 75, 10) text:[NSString stringWithFormat:@"%ld分钟",model.length] color:[UIColor whiteColor]];
            self.timeLabel.font = [UIFont systemFontOfSize:14.0];
            self.typeLabel = [UILabel labelWithFrame:CGRectMake(kScreenWidth / 2 , (135), (120), (10)) text:model.type color:[UIColor whiteColor]];
            self.typeLabel.font = [UIFont systemFontOfSize:14.0];
        }
        [view addSubview:_carousel];
        [view addSubview:_topLabel];
        [view addSubview:_timeLabel];
        
        UILabel * sepLabel = [UILabel labelWithFrame:CGRectMake(kScreenWidth / 2 -18, 137,10, (10)) text:@"一" color:[UIColor whiteColor]];
        
        [view addSubview:sepLabel];
        [view addSubview:_typeLabel];
        
        
        
        return view;

    }else{
        return view;
    }}

// 设置模糊背景
- (UIImageView *)lurImageView
{
    UIImageView *backImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kImageH(160))];
    backImage.image = [UIImage imageNamed:@"step.jpg"];
    backImage.userInteractionEnabled = YES;
    UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]];
    visualEffectView.frame = backImage.bounds;
    visualEffectView.alpha = 0.7;
    [backImage addSubview:visualEffectView];
    return backImage;
    
}
#pragma mark - iCarousel methods
- (NSInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
    return _moviesArray.count;
}

- (UIView *) carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view
{
    view = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 150, 100)];
    [((UIImageView *)view) sd_setImageWithURL:_set[index] placeholderImage:[UIImage imageNamed:@"2.jpg"] completed:nil];
    
    return view;
}

- (void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index
{
    
    FPMovieHotPlayModel *model = _moviesArray[index];
    self.topLabel.text  = model.title;
    self.timeLabel.text = [NSString stringWithFormat:@"%ld分钟 ",model.length];
    self.typeLabel.text = model.type;
    model = nil;
}

- (void)carouselCurrentItemIndexDidChange:(iCarousel *)carousel
{
    if (carousel.currentItemIndex != -1) {
        _ischange = YES;
    }
    _caIndex = carousel.currentItemIndex;
    FPMovieHotPlayModel *model = _moviesArray[carousel.currentItemIndex];
    self.topLabel.text  = model.title;
    self.timeLabel.text = [NSString stringWithFormat:@"%ld分钟 ",model.length];
    self.typeLabel.text = model.type;
    if (_caIndex == -1) {
        _caIndex = 0;
    }
    [self S_analisisPlayMessageMovieId:model.movieId movieData:[_dateArray[_caIndex] objectAtIndex:_lblIndex]];
    [self.collectionView reloadData];
}

#pragma mark - 返回cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        static NSString *cellIdentifier = @"cell1";
        [tableView registerClass:[FPCinema_TableViewCell class] forCellReuseIdentifier:cellIdentifier];
        FPCinema_TableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        FPCinemaModel *model        = self.cinemaArray[0];
        FPCinemaModel *feature      = self.featureArray[0];
        
        cell.cinemaNameLabel.text   = model.name;
        cell.addressLabel.text      = model.address;
        cell.distanceLabel.text     = [NSString stringWithFormat:@"%@km",self.distance];
        feature.hasPark ? (cell.parkImageView.hidden = NO) : (cell.parkImageView.hidden = YES);
        feature.hasWifi ? (cell.wifiImageView.hidden = NO) : (cell.wifiImageView.hidden = YES);
        feature.has3D ? (cell.thirdDImageView.hidden = NO) : (cell.thirdDImageView.hidden = YES);
        feature.hasServiceTicket ? (cell.ATSImageView.hidden = NO) : (cell.ATSImageView.hidden = YES);
        feature.hasVIP ? (cell.vipImageView.hidden = NO) : (cell.vipImageView.hidden = YES);
        cell.nextImageView.image = [UIImage imageNamed:@"forward-vector"];
        cell.upLabel.text = nil;
        cell.priceLabel.text = nil;
        cell.moneyLabel.text = nil;
        return cell;
    }else{
        static NSString *cellIdentifier = @"cell2";
        [tableView registerClass:[FPDetailCinemaTableViewCell class] forCellReuseIdentifier:cellIdentifier];
        FPDetailCinemaTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
        
        FPPlayDetailModel *model = self.playDetailArray[indexPath.row];
        //        [cell.DetailButton addTarget:self action:@selector(DetailButton:) forControlEvents:UIControlEventTouchUpInside];
        cell.playTypeLabel.text  = [NSString stringWithFormat:@"%@/%@",model.versionDesc,model.language];
        cell.playAddrLabel.text  = model.hall;
        cell.priceLabel.text     = [NSString stringWithFormat:@"%ld",model.price];
        
        NSInteger startTime = [model.showDay integerValue];
        NSInteger endTime   = [model.showDay integerValue] + model.length*60;
        NSDate *startDate   = [NSDate dateWithTimeIntervalSince1970:startTime];
        NSDate *endDate     = [NSDate dateWithTimeIntervalSince1970:endTime];
        NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
        [dateFormat setDateFormat:@"HH:mm"];
        NSString *startDateString = [dateFormat stringFromDate:startDate];
        NSString *endDateString   = [dateFormat stringFromDate:endDate];
        cell.startTimeLabel.text  = startDateString;
        cell.endTimeLabel.text    = endDateString;
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
    
}

- (void)DetailButton:(UIButton *)button
{
    NSLog(@"点击查看影片详情");
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        FPCinemaDetailViewController *fpCinemaDetailVC = [[FPCinemaDetailViewController alloc] init];
        FPCinemaModel *model = self.cinemaArray[0];
        fpCinemaDetailVC.kUrl = [NSString stringWithFormat:@"%ld",model.cinemaId];
//        [self.navigationController pushViewController:fpCinemaDetailVC animated:YES];
        [self presentViewController:fpCinemaDetailVC animated:YES completion:nil];
    }else{
        
    }
}

/*==============================================collectionView协议方法=================================================*/
#pragma mark - collectionView协议方法
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    if (self.dateArray.count != 0) {
        
    if (_caIndex == -1) {
        _caIndex = 0;
    }
    return [self.dateArray[_caIndex] count] ;
    }else{
        return 0;
    }
}

#pragma mark - 返回cell
// 返回collectionViewCell
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"collectionCell";
    [collectionView registerClass:[FPCinemaCollectionViewCell class] forCellWithReuseIdentifier:cellIdentifier];
    FPCinemaCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
    if (_caIndex == -1) {
        _caIndex = 0;
    }
    
    cell.label.text = [self.dateArray[_caIndex] objectAtIndex:indexPath.row];
    
    if (_isClick == YES) {
        (indexPath.item == _lblIndex) ? (cell.label.textColor = [UIColor orangeColor]) : (cell.label.textColor = [UIColor lightGrayColor]);
    }else{
        (indexPath.item == 0) ? (cell.label.textColor = [UIColor orangeColor]) : (cell.label.textColor = [UIColor lightGrayColor]);
    }
    
    return cell;
}

// collection点击cell方法
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    for (FPCinemaCollectionViewCell *cell in collectionView.visibleCells) {
        cell.label.textColor = [UIColor lightGrayColor];
    }
    if (_caIndex == -1) {
        _caIndex = 0;
    }
    self.lblIndex = indexPath.row;
    _isClick = YES;
    FPCinemaCollectionViewCell *cell = (FPCinemaCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
    cell.label.textColor = [UIColor orangeColor];
    // 传值
    FPMovieHotPlayModel *model = _moviesArray[_caIndex];
    self.datakUrl = _dateArray[_caIndex][indexPath.item];
    self.movieIdkUrl = model.movieId;
    NSLog(@"%ld",model.movieId);
    [self S_analisisPlayMessageMovieId:model.movieId movieData:_dateArray[_caIndex][_lblIndex]];
}

//----返回cell宽和高
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(kScreenWidth / 3, 30);
}



@end
